import java.util.HashMap;
import java.util.Map;

public class PeopleAwareOfSecret {

    public static void main(String[] args) {
        PeopleAwareOfSecret peopleAwareOfSecret = new PeopleAwareOfSecret();
        System.out.println(peopleAwareOfSecret.peopleAwareOfSecret(684,18,496));
    }

    public int peopleAwareOfSecret1(int n, int delay, int forget) {
        HashMap<Integer, Integer> mapForget = new HashMap<>();
        HashMap<Integer, Integer> mapDelay = new HashMap<>();
        int[] dp = new int[n];
        dp[0] = 1;
        mapDelay.put(delay, 1);
        mapForget.put(forget, 1);
        for (int i = 1; i < n; i++) {
            HashMap<Integer, Integer> mapDelayNew = new HashMap<>();
            mapDelayNew.put(0, mapDelay.getOrDefault(0, 0));
            for (Map.Entry<Integer, Integer> entry : mapDelay.entrySet()) {
                if (entry.getKey() != 0) {
                    mapDelayNew.put(entry.getKey() - 1, entry.getValue()
                            + mapDelayNew.getOrDefault(entry.getKey() - 1, 0));
                }
            }
            mapDelay = mapDelayNew;
            HashMap<Integer, Integer> mapForgetNew = new HashMap<>();
            for (Map.Entry<Integer, Integer> entry : mapForget.entrySet()) {
                mapForgetNew.put(entry.getKey() - 1, entry.getValue()
                        + mapForgetNew.getOrDefault(entry.getKey() - 1, 0));
            }
            mapForget = mapForgetNew;
            int delta = mapDelay.getOrDefault(0, 0) - mapForget.getOrDefault(0, 0) * 2;
            dp[i] = dp[i - 1] + delta;
            int count = mapDelay.getOrDefault(0, 0) - mapForget.getOrDefault(0, 0);
            while (count > 0) {
                mapDelay.put(delay, mapDelay.getOrDefault(delay, 0) + 1);
                mapForget.put(forget, mapForget.getOrDefault(forget, 0) + 1);
                --count;
            }
            mapDelay.put(0, mapDelay.getOrDefault(0, 0) - mapForget.getOrDefault(0, 0));
            mapForget.remove(0);
        }
        return dp[n - 1];
    }

    public int peopleAwareOfSecret2(int n, int delay, int forget) {
        int[] dp = new int[n];
        final int MOD = (int) (Math.pow(10 ,9) + 7);
        int[] numDelay = new int[delay + 1];
        int[] numForget = new int[forget + 1];
        dp[0] = 1;
        numForget[forget] = 1;
        numDelay[delay] = 1;
        for (int i = 1; i < n; i++) {
            int[] newDelay = new int[delay + 1];
            newDelay[0] = (numDelay[0] + numDelay[1]) % MOD;
            for (int j = delay; j >= 2; j--) {
                newDelay[j - 1] = numDelay[j];
            }
            numDelay = newDelay;
            int[] newForget = new int[forget + 1];
            for (int j = forget; j >= 1; j--) {
                newForget[j - 1] = numForget[j];
            }
            numForget = newForget;
            int delta = (numDelay[0] - 2 * numForget[0]) % MOD;
            dp[i] = (dp[i - 1] + delta) % MOD;
            int count = (numDelay[0] - numForget[0]) % MOD;
            while (count > 0) {
                numDelay[delay] = (numDelay[delay] + 1) % MOD;
                numForget[forget] = (numForget[forget] + 1) % MOD;
                --count;
            }
            numDelay[0] -= numForget[0];
            numForget[0] = 0;
        }
        return dp[n - 1];
    }

    public int peopleAwareOfSecret(int n, int delay, int forget) {
        final int MOD = (int) (Math.pow(10 ,9) + 7);
        int[] dp = new int[n + 1];
        dp[1] = 1;
        long ans = 1;
        for (int i = 2; i < n + 1; i++) {
            for (int j = Math.max(i - forget + 1, 1); j <= i - delay; j++) {
                dp[i] = (dp[i] + dp[j]) % MOD;
            }
            ans += dp[i];
            ans -= i - forget > 0 ? dp[i - forget] : 0;
        }
        return (int) (ans % MOD);
    }
}
